package com.mida.app.report.controller;

import com.mida.app.report.service.DocPatientInfoService;
import com.mida.app.report.service.MdmService;
import com.mida.app.report.vo.DocReportListPageVo;
import com.mida.app.report.vo.DocReportListVo;
import com.mida.bms.report.vo.PatientInfoParameterVo;
import com.mida.dms.mdm.dto.UserDto;
import com.mida.tool.common.result.ListResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 数字患者
 */
@RestController
@RequestMapping("/docPatientInfo")
@CrossOrigin
@Slf4j
public class DocPatientInfoController {

    @Autowired
    private DocPatientInfoService docPatientInfoService;

    @Autowired
    private MdmService mdmService;

    /**
     * getPatientInfo
     * @param vo
     * @return
     */
    @PostMapping(value = "getPatientInfo",produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ListResult getPatientInfo(@RequestBody PatientInfoParameterVo vo) {
        ListResult listResult;
        try {
            return docPatientInfoService.getPatientInfo(vo);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            listResult = new ListResult();
            listResult.setMessage("getPatientInfo处理失败");
            listResult.setStatus(HttpStatus.BAD_REQUEST.value());
            return listResult;
        }
    }

    /**
     * getPatientVisitInfo
     * @param vo
     * @return
     */
    @PostMapping("getPatientVisitInfo")
    @ResponseBody
    public ListResult getPatientVisitInfo(@RequestBody PatientInfoParameterVo vo) {
        ListResult listResult;
        try {
            return docPatientInfoService.getPatientVisitInfo(vo);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            listResult = new ListResult();
            listResult.setMessage("getPatientVisitInfo处理失败");
            listResult.setStatus(HttpStatus.BAD_REQUEST.value());
            return listResult;
        }
    }

    /**
     * 取得未写报告患者列表
     * @param vo
     * @return
     */
    @PostMapping("getPatientList")
    @ResponseBody
    public ListResult<DocReportListVo> getPatientList(HttpServletRequest request, @RequestBody DocReportListPageVo vo) {

        ListResult listResult = new ListResult();
        try {
            listResult = docPatientInfoService.getPatientList(vo);
            return listResult;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            listResult = new ListResult();
            listResult.setMessage("取得未写报告患者列表处理失败");
            listResult.setStatus(HttpStatus.BAD_REQUEST.value());
            return listResult;
        }
    }
}

